home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #45 (Jun 89) / Forth Code / INIT runner < prev    next >
Text File  |  1989-04-16  |  951b  |  44 lines

  1. \ INIT 12 starter
  2. \ J. Langowski / MacTutor April 1989
  3. \ Thanks to Eric Carrasco (Calvacom EC10) to this idea
  4. \ which he implemented in Pascal
  5.  
  6. : $open-res { addr | refNum -- result }
  7.     addr call openresfile -> refNum
  8.     call ResError L_ext
  9.     dup not IF drop refNum THEN 
  10. ;
  11.  
  12. : $close-res call CloseResFile call ResError L_ext ;
  13.  
  14. $4E714E71 CONSTANT nopnop
  15.  
  16. : runINIT { | refNum hINIT -- }
  17.     " theInit" $open-res -> refNum
  18.     refNum 0 > IF
  19.         ascii INIT 12 call GetResource -> hINIT
  20.         hINIT IF
  21.             hINIT call HomeResFile
  22.             refNum = IF
  23.                 hINIT call DetachResource
  24.                 hINIT @ execute        \ run the INIT
  25.                 nopnop hINIT @ !     \ fill first 2 words with NOPs
  26.             ELSE
  27.                 " INIT not from my file" 0 0 0 call ParamText
  28.                 1000 0 call NoteAlert drop
  29.             THEN
  30.         ELSE
  31.             " Can't find INIT 12 resource" 0 0 0 call ParamText
  32.             1000 0 call NoteAlert drop
  33.         THEN
  34.     ELSE
  35.         " Can't open file 'theINIT'" 0 0 0 call ParamText
  36.         1000 0 call NoteAlert drop
  37.     THEN
  38.     bye
  39. ;
  40.  
  41.     
  42.                 
  43.  
  44.